package com.bdqn.tour.service.impl;



import com.bdqn.tour.dao.HzyLocationDao;
import com.bdqn.tour.dao.impl.HzyLocationDaoImpl;
import com.bdqn.tour.pojo.HzyLocation;
import com.bdqn.tour.pojo.HzyPageInfo;
import com.bdqn.tour.service.HzyLocationService;

import java.util.List;

public class HzyLocationServiceImpl implements HzyLocationService {
    HzyLocationDao hzyLocationDao = new HzyLocationDaoImpl();
    @Override
    public boolean addLocation(HzyLocation location) {
        return hzyLocationDao.addLocation(location);
    }

    @Override
    public boolean deleteLocation(int id) {
        return hzyLocationDao.deleteLocation(id);
    }

    @Override
    public boolean updateLocation(HzyLocation location) {
        return hzyLocationDao.updateLocation(location);
    }

    @Override
    public HzyPageInfo<HzyLocation> getLocationPage(int pageNo, int pageSize) {
        // 创建分页对象
        HzyPageInfo<HzyLocation> pageInfo = new HzyPageInfo<>();
        pageInfo.setPageSize(pageSize);
        pageInfo.setCurrPageNo(pageNo);

        // 获取总记录数
        int totalCount = hzyLocationDao.getTotalCount();
        pageInfo.setTotals(totalCount);

        // 获取当前页数据
        List<HzyLocation> locations = hzyLocationDao.getLocationList(pageNo, pageSize);
        pageInfo.setList(locations);

        return pageInfo;
    }

    @Override
    public HzyLocation getLocationById(int id) {
        return hzyLocationDao.getLocationById(id);
    }
}
